package edu.towson.cosc490.incaseofemergency.objects;

import static android.provider.BaseColumns._ID;
import static edu.towson.cosc490.incaseofemergency.objects.Constants.KIT_TABLE_NAME;
import static edu.towson.cosc490.incaseofemergency.objects.Constants.ITEM_NAME;
import static edu.towson.cosc490.incaseofemergency.objects.Constants.AMOUNT_REQUIRED;
import static edu.towson.cosc490.incaseofemergency.objects.Constants.AMOUNT_OWNED;
import static edu.towson.cosc490.incaseofemergency.objects.Constants.PERISHABLE;
import static edu.towson.cosc490.incaseofemergency.objects.Constants.EXPIRATON_DATE;
import static edu.towson.cosc490.incaseofemergency.objects.Constants.KIT_TYPE_FILTER;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class SupplyKitData extends SQLiteOpenHelper{
	private static final String  DATABASE_NAME = "supplykit.db";
	private static final int DATABASE_VERSION = 1;

	public SupplyKitData(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		db.execSQL("CREATE TABLE " + KIT_TABLE_NAME + " (" + _ID
	            + " INTEGER PRIMARY KEY AUTOINCREMENT, "  
	    		+ ITEM_NAME + " TEXT," + AMOUNT_REQUIRED + " TEXT, " 
	            + AMOUNT_OWNED + " TEXT, " + PERISHABLE + " TEXT, "
	            + EXPIRATON_DATE + " TEXT, " + KIT_TYPE_FILTER + " TEXT);");
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		 db.execSQL("DROP TABLE IF EXISTS " + KIT_TABLE_NAME);
	     onCreate(db);
	}
}
